<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;

use app\common\model\NoticeCategory;

/**
 * Notice控制器
 */
class Notice extends AdminBase
{
    
    /**
     * Notice列表
     */
    public function NoticeList()
    {
        
        $where = $this->logicNotice->getWhere($this->param);
        
        $this->assign('list', $this->logicNotice->getNoticeList($where, 'a.*', 'a.create_time desc'));
        $this->assign('cate',NoticeCategory::all(['status'=>1]));
        $this->assign('param', $this->param);
        return $this->fetch('Notice_list');
    }
    
    /**
     * Notice添加
     */
    public function NoticeAdd()
    {
        
        $this->NoticeCommon();
        
        return $this->fetch('Notice_edit');
    }
    
    /**
     * Notice编辑
     */
    public function NoticeEdit()
    {
        
        $this->NoticeCommon();

        $info = $this->logicNotice->getNoticeInfo(['a.id' => $this->param['id']], 'a.*');


        $this->assign('info', $info);
        
        return $this->fetch('Notice_edit');
    }
    
    /**
     * Notice添加与编辑通用方法
     */
    public function NoticeCommon()
    {
        
        IS_POST && $this->jump($this->logicNotice->NoticeEdit($_POST));
        $this->assign('cate',NoticeCategory::all(['status'=>1]));

    }


    /**
     * 文章分类添加
     */
    public function noticeCategoryAdd()
    {

        IS_POST && $this->jump($this->logicnotice->noticeCategoryEdit($this->param));

        return $this->fetch('notice_category_edit');
    }

    /**
     * 文章分类编辑
     */
    public function noticeCategoryEdit()
    {

        IS_POST && $this->jump($this->logicnotice->noticeCategoryEdit($this->param));

        $info = $this->logicnotice->getnoticeCategoryInfo(['id' => $this->param['id']]);

        $this->assign('info', $info);

        return $this->fetch('notice_category_edit');
    }

    /**
     * 文章分类列表
     */
    public function noticeCategoryList()
    {

        $this->assign('list', $this->logicnotice->getnoticeCategoryList( []));

        return $this->fetch('notice_category_list');
    }


    /**
     * 文章分类删除
     */
    public function noticeCategoryDel($id = 0)
    {

        $this->jump($this->logicnotice->noticeCategoryDel(['id' => $id]));
    }



    

    /**
     * 数据状态设置
     */
    public function setStatus()
    {
        
        $this->jump($this->logicAdminBase->setStatus('Notice', $this->param));
    }
}
